<?
if (!$isInstallProgram)
	exit;
	
echo "<table width='100%' align='center'><tr><td>";
echo "<b>Filepermission Check</b><br />Note #1: Only <b>Classifieds</b> and <b>admin</b> directory needs to be chmod $chmod. The script will
create all red-marked directories below if you have done that and pushed Retry.<br /><br />";

echo "<br /><br />";
	
	// ADMIN
	$dirArray[]=$dir . "";
	$dirArray[]=$dir . "/admin";
	$dirArray[]=$dir . "/admin/config";
	$dirArray[]=$dir . "/admin/config/backup";
	$dirArray[]=$dir . "/admin/config/logs";
	$dirArray[]=$dir . "/admin/config/cache";
	$dirArray[]=$dir . "/admin/config/language";
	$dirArray[]=$dir . "/admin/config/options";
	$dirArray[]=$dir . "/admin/config/templates";
	$dirArray[]=$dir . "/admin/config/templates_c";
	$dirArray[]=$dir . "/images";
	$dirArray[]=$dir . "/images/banners";
	$dirArray[]=$dir . "/images/videos";
	$dirArray[]=$dir . "/images/docs";
	$dirArray[]=$dir . "/images/vendors";
	$dirArray[]=$dir . "/wap";
	
	echo "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\">"; 
    echo "<tr> <td style=\"border:0px;\">File Name</b></td>"; 
    echo "<td style=\"border:0px;\">Needed Chmod</b></td>"; 
    echo "<td style=\"border:0px;\">Current Chmod</b></td>"; 
    echo "</tr>"; 
    

    $num=0;
    $num=$_SESSION["test"];
    $ok_color="#91f587;";
    $fail_color="#fd7a7a;";
    foreach ($dirArray as $lItem) 
    {
    	@mkdir($lItem,octdec($chmod)); 
    	@chmod($lItem,octdec($chmod));
    	
    	$color=$ok_color;
    	$lReturnArray=checkWrite($lItem,$chmod,0);
    	
    	if ($lReturnArray["writeable"]==false)
    	{
    		$lError=1; 
    	 	$stop=1;
    	 	$color=$fail_color;
    	}
    	echo "<tr style=background-color:".$color.">";  
    	echo "<td style=\"border:0px;\">". $lItem ."</td>";  
    	echo "<td style=\"border:0px;\">$chmod</td>";  
    	echo "<td style=\"border:0px;\">".$lReturnArray["permission"]."</td>";  
    	echo "</tr>";   
    	
    }
    @copy("$dir/admin/setup/configuration_src/htaccess.txt", "$dir/admin/config/logs/.htaccess");
    @copy("$dir/admin/setup/configuration_src/htaccess.txt", "$dir/admin/config/backup/.htaccess");
    @copy("$dir/admin/setup/configuration_src/htaccess.txt", "$dir/admin/config/cache/.htaccess");
    @copy("$dir/admin/setup/configuration_src/htaccess.txt", "$dir/includes/.htaccess");


    
	echo "</table>"; 

	echo "<tr><td colspan='3' align='right'>"; 
	if ($lError)
		echo "<b><font color='red'>Warning:</font></b> Please correct the above errors<br><a href='?level=1'><u>Click here to try again</u></a> to check if you are ready";
	else
		echo "<b><font color='green'>Filepermission OK!</font></b>";
	
	echo "</td></tr></table>";

	$lError="";	
	
	
	echo "<b>PHP Configuration Check</b><br /><br />";
	echo "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\">"; 
    echo "<tr> <td style=\"border:0px;\">PHP Setting</b></td>"; 
    echo "<td style=\"border:0px;\">Needed Value</b></td>"; 
    echo "<td style=\"border:0px;\">Current Value</b></td>"; 
    echo "</tr>"; 
	if (!ini_get('register_globals'))
		echo "<tr style='background-color:#91f587;'><td>register_globals</td><td>off</td><td>off</td></tr>";
	else 
	{
		echo "<tr style='background-color:#fd7a7a;'><td>register_globals</td><td>off</td><td>on</td></tr>";
		$stop=1;
		$lError=1;
	}
	
	if (ini_get('magic_quotes_gpc'))
		echo "<tr style='background-color:#91f587;'><td>magic_quotes_gpc</td><td>on</td><td>on</td></tr>";
	else 
	{
		echo "<tr style='background-color:#fd7a7a;'><td>magic_quotes_gpc</td><td>on</td><td>off</td></tr>";
		$stop=1;
		$lError=1;
	}
	
	if (!ini_get('safe_mode'))
		echo "<tr style='background-color:#91f587;'><td>safe_mode</td><td>off</td><td>off</td></tr>";
	else 
	{
		echo "<tr style='background-color:#fd7a7a;'><td>safe_mode</td><td>off</td><td>on</td></tr>";
		$stop=1;
		$lError=1;
	}
	
	if (!version_compare("4.0", phpversion(), ">")==1)
		echo "<tr style='background-color:#91f587;'><td>PHP Version</td><td>4.1 and later</td><td>".phpversion()."</td></tr>";
	else 
	{
		echo "<tr style='background-color:#fd7a7a;'><td>PHP Version</td><td>4.1 and later</td><td>".phpversion()."</td></tr>";
		$stop=1;
		$lError=1;
	}
	
	if ($num==1)
		echo "<tr style='background-color:#91f587;'><td>Session Test</td><td>Must work</td><td>Tested: OK</td></tr>";
	else 
	{
		echo "<tr style='background-color:#fd7a7a;'><td>Session Test</td><td>Should work</td><td>Sessions NOT working</td></tr>";
		$stop=1;
		$lError=1;
	}
	

	echo "<tr><td colspan='3' align='right'>"; 
	
	if ($lError)
		echo "<b><font color='red'>Warning:</font></b> Please correct the above errors.
		This can be done by editing your servers <b>php.ini</b> file and changing the above mentioned values.
		You can also change these settings per directory by using .htaccess or php.ini files.
		
		<br><a href='?level=1'><u>Click here to try again</u></a> to check if you are ready";
	else
		echo "<b><font color='green'>PHP Configuration OK!</font></b>";
	
	echo "</table>";	
	
	
	if (!$stop)
		print("<center><h3><a href='install.php?level=2'><img src='layout_images/arrow-forw.gif' border='0'> <u>Next Step</u></a></h3></center></center>");

echo "</td></tr></table>";
	
	
?>